 
package com.unuo.e4.chouse.parts;

import javax.annotation.PostConstruct;
import javax.inject.Inject;

import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

import com.hexapixel.widgets.generic.ColorCache;
import com.hexapixel.widgets.generic.ImageCache;
import com.hexapixel.widgets.ribbon.RibbonButton;
import com.hexapixel.widgets.ribbon.RibbonButtonGroup;
import com.hexapixel.widgets.ribbon.RibbonCheckbox;
import com.hexapixel.widgets.ribbon.RibbonGroup;
import com.hexapixel.widgets.ribbon.RibbonTab;
import com.hexapixel.widgets.ribbon.RibbonTabFolder;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.GridData;

public class SchedulePart {
	
    private Composite topComposite;
    private Composite pageComposite;
	
	@Inject
	public SchedulePart() {
		//TODO Your code here
	}
	
	@PostConstruct
	public void postConstruct(Composite parent,MApplication application,EModelService eModelService) {
		parent.getShell().setBackground(ColorCache.getInstance().getColor(182, 206, 238));
//        parent.setLayout(new FillLayout(SWT.HORIZONTAL));
        // TODO Auto-generated method stub
//        defaultLayout = new TrimLayout();
//        defaultLayout.setSpacing(2, 2, 2, 2);
//        defaultLayout.setMargins(2, 2);
//        shell.setLayout(defaultLayout);
        
        //topComposite
        topComposite = new Composite(parent, SWT.None);
        topComposite.setBackground(ColorCache.getInstance().getColor(182, 206, 238));
            topComposite.setLayout(new GridLayout(1, false));
        
            final RibbonTabFolder ftf = new RibbonTabFolder(topComposite, SWT.NONE);
            ftf.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
            RibbonTab ft0 = new RibbonTab(ftf, "Home");
            RibbonTab ft1 = new RibbonTab(ftf, "Insert");
            RibbonGroup rg = new RibbonGroup(ft0, "Hello");
            RibbonButtonGroup rbg = new RibbonButtonGroup(rg);
            RibbonButton btn = new RibbonButton(rbg, ImageCache.getImage("books_16.gif"), "RIBBON BTN", SWT.NONE);
            
            new RibbonTab(ftf, "Page Layout");
            new RibbonTab(ftf, "References");
            
            Label lb = new Label(topComposite, SWT.NONE);
            lb.setText("Thie my first ribbon app.");
            
            Text txt = new Text(topComposite, SWT.BORDER);
            txt.setText("please input your name.");
            MUIElement ele1 = eModelService.find(
    				"com.taocares.naoms.fims.client.appmodel.trimmedwindow.msgWin",
    				application);
            MPart win = (MPart) ele1;
        
//        topCompositeTrim = new WindowTrimProxy(topComposite,"org.eclipse.ui.internal.WorkbenchWindow.topBar", WorkbenchMessages.TrimCommon_Main_TrimName, SWT.NONE, true);
        
//        pageComposite = (Composite) ((WorkbenchWindowConfigurer) getWindowConfigurer()).createPageComposite(shell);
//        setLayoutDataForContents();
    }

    private void setLayoutDataForContents() {
        updateLayoutDataForContents();
    }

    private void updateLayoutDataForContents() {
//        if (defaultLayout == null) {
//            return;
//        }
//        defaultLayout.addTrim(SWT.TOP, topCompositeTrim);
//        topComposite.setVisible(true);
//        
//        pageComposite.setBackground(ColorCache.getInstance().getColor(182, 206, 238));
//        defaultLayout.setCenterControl(pageComposite);
        
    }

	
}